---------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix3.2.log
  log type:  text
 opened on:  12 May 2025, 17:47:47

. use "C:\Users\sbstjp\OneDrive - Cardiff University\anes_timeseries_2024_stata_20250219.dta" // ANES 2024 Time
>  Series Study // Preliminary Release: Pre-Election Data February 19, 2025 version

. 
. // Create social justice scale
. * Rename variables 
. rename V241290x Edi 

. rename V241372x Tgbathroom 

. rename V241375x Tgsport 

. rename V241412x Appprotestgaza 

. 
. * Delete missing values
. foreach var in Edi Tgbathroom Tgsport Appprotestgaza {
  2.     replace `var' = . if `var' < 0
  3.     tabulate `var', missing
  4. }
(308 real changes made, 308 to missing)

PRE: SUMMARY Approve/disapprove |
         Diversity, Equity, and |
                Inclusion (DEI) |      Freq.     Percent        Cum.
--------------------------------+-----------------------------------
          1. Favor a great deal |        427       12.75       12.75
     2. Favor a moderate amount |        465       13.88       26.63
              3. Favor a little |        147        4.39       31.02
    4. Neither favor nor oppose |      1,129       33.71       64.74
             5. Oppose a little |         99        2.96       67.69
    6. Oppose a moderate amount |        272        8.12       75.81
         7. Oppose a great deal |        502       14.99       90.80
                              . |        308        9.20      100.00
--------------------------------+-----------------------------------
                          Total |      3,349      100.00
(278 real changes made, 278 to missing)

                  PRE: SUMMARY: |
 Approve/disapprove transgender |
       people use bathroom that |
                     matches ge |      Freq.     Percent        Cum.
--------------------------------+-----------------------------------
          1. Favor a great deal |        486       14.51       14.51
     2. Favor a moderate amount |        274        8.18       22.69
              3. Favor a little |         97        2.90       25.59
    4. Neither favor nor oppose |        744       22.22       47.81
             5. Oppose a little |         75        2.24       50.04
    6. Oppose a moderate amount |        219        6.54       56.58
         7. Oppose a great deal |      1,176       35.11       91.70
                              . |        278        8.30      100.00
--------------------------------+-----------------------------------
                          Total |      3,349      100.00
(277 real changes made, 277 to missing)

     PRE: SUMMARY: Favor/oppose |
 banning transgender girls from |
              K-12 girls sports |      Freq.     Percent        Cum.
--------------------------------+-----------------------------------
          1. Favor a great deal |      1,127       33.65       33.65
     2. Favor a moderate amount |        254        7.58       41.24
              3. Favor a little |         95        2.84       44.07
    4. Neither favor nor oppose |        814       24.31       68.38
             5. Oppose a little |         78        2.33       70.71
    6. Oppose a moderate amount |        243        7.26       77.96
         7. Oppose a great deal |        461       13.77       91.73
                              . |        277        8.27      100.00
--------------------------------+-----------------------------------
                          Total |      3,349      100.00
(288 real changes made, 288 to missing)

    PRE: SUMMARY: Approve/disapprove of |
           protests against war in Gaza |      Freq.     Percent        Cum.
----------------------------------------+-----------------------------------
           1. Approve a lot of protests |        278        8.30        8.30
2. Approve a moderate amount of protest |        298        8.90       17.20
        3. Approve a little of protests |        136        4.06       21.26
4. Neither approve nor disapprove of pr |      1,135       33.89       55.15
     5. Disapprove a little of protests |        129        3.85       59.00
6. Disapprove a moderate amount of prot |        335       10.00       69.01
        7. Disapprove a lot of protests |        750       22.39       91.40
                                      . |        288        8.60      100.00
----------------------------------------+-----------------------------------
                                  Total |      3,349      100.00

. 
. *Reverse coding so social justice values are high
. foreach var in Appprotestgaza Tgbathroom Edi {
  2.     qui sum `var'
  3.     local max_value = r(max)
  4.     gen r`var' = `max_value' + 1 - `var'
  5. }
(288 missing values generated)
(278 missing values generated)
(308 missing values generated)

. 
. *Standardize items in the scale from 1-2 - this avoids 0, for reasons outlined in next step
. foreach var in rEdi rTgbathroom Tgsport rAppprotestgaza {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        rEdi |      3,041    4.068727      1.9484          1          7
(308 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
 rTgbathroom |      3,071    3.368935    2.274272          1          7
(278 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
     Tgsport |      3,072    3.336914    2.217592          1          7
(277 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
rAppprotes~a |      3,061    3.515518    1.924261          1          7
(288 missing values generated)

. 
. *At this point, the scale has a Cronbach's alpha of 0.76. 
. 
. * Replace missing values with 0 for the specified variables - this is necessary as Stata doesn't add up missi
> ng values and means a 0-1 standardization scale isn't feasible as missing values would overlap with the scale
. foreach var in srEdi srTgbathroom sTgsport srAppprotestgaza {
  2.     replace `var' = 0 if missing(`var')
  3. }
(308 real changes made)
(278 real changes made)
(277 real changes made)
(288 real changes made)

. 
. * Initialize the total score and the count of non-zero responses
. gen total_scoreSJV = 0

. gen count_nonzeroSJV = 0

. 
. * Add each variable to the total scale score and count it if non-zero
. foreach var in srEdi srTgbathroom sTgsport srAppprotestgaza  {
  2.     replace total_scoreSJV = total_scoreSJV + `var'
  3.     replace count_nonzeroSJV = count_nonzeroSJV + (`var' != 0)
  4. }
(3,041 real changes made)
(3,041 real changes made)
(3,071 real changes made)
(3,071 real changes made)
(3,072 real changes made)
(3,072 real changes made)
(3,061 real changes made)
(3,061 real changes made)

. 
. * Calculate the average score, avoiding division by zero
. gen socJusValues = .
(3,349 missing values generated)

. replace socJusValues = total_scoreSJV / count_nonzeroSJV if count_nonzeroSJV > 0
(3,097 real changes made)

. 
. // Liberalism scale
. * Rename
. rename V241269x bordersecurity

. rename V241302 abortion

. rename V241272x crime

. rename V241308x deathpenalty

. rename V241395x wall

. rename V241389x birthrightcit

. rename V241381x gayadoption

. rename V241258 environment

. 
. *Drop missing values
. foreach var in gayadoption bordersecurity crime deathpenalty wall birthrightcit {
  2.     replace `var' = . if inlist(`var', -1, -2)
  3. }
(322 real changes made, 322 to missing)
(269 real changes made, 269 to missing)
(264 real changes made, 264 to missing)
(319 real changes made, 319 to missing)
(266 real changes made, 266 to missing)
(269 real changes made, 269 to missing)

. 
. replace abortion = . if inlist(abortion, -9, -8, -1, 5)   
(377 real changes made, 377 to missing)

. replace environment = . if inlist(environment, -9, -8, -1, 99)  
(722 real changes made, 722 to missing)

. 
. *Reverse code so liberal values are high
. foreach var in gayadoption environment {
  2.     qui sum `var'
  3.     local max_value = r(max)
  4.     gen r`var' = `max_value' + 1 - `var'
  5. }
(322 missing values generated)
(722 missing values generated)

.  
. *Standardize items in the scale from 1-2 - this avoids 0, for reasons outlined in next step
. foreach var in bordersecurity abortion crime deathpenalty wall birthrightcit rgayadoption renvironment {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
bordersecu~y |      3,080    1.963961    1.158024          1          5
(269 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
    abortion |      2,972    3.145693    .9763123          1          4
(377 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
       crime |      3,085    2.023663    1.064897          1          5
(264 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
deathpenalty |      3,030    2.167327    1.139084          1          4
(319 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
        wall |      3,083    3.748621    2.345843          1          7
(266 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
birthright~t |      3,080    4.441558    2.129723          1          7
(269 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
rgayadoption |      3,027    4.677569    1.768987          1          6
(322 missing values generated)

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
renvironment |      2,627    4.839741    1.947476          1          7
(722 missing values generated)

. 
. * Replace missing values with 0 for the specified variables - this is necessary as Stata doesn't add up missi
> ng values and means a 0-1 standardization scale isn't feasible as missing values would overlap with the scale
. foreach var in sbordersecurity sabortion scrime sdeathpenalty swall sbirthrightcit srgayadoption srenvironmen
> t {
  2.     replace `var' = 0 if missing(`var')
  3. }
(269 real changes made)
(377 real changes made)
(264 real changes made)
(319 real changes made)
(266 real changes made)
(269 real changes made)
(322 real changes made)
(722 real changes made)

. 
. * Initialize the total score and the count of non-zero responses
. gen total_scoreAL = 0

. gen count_nonzeroAL = 0

. 
. * Add each variable to the total scale score and count it if non-zero
. foreach var in sbordersecurity sabortion scrime sdeathpenalty swall sbirthrightcit srgayadoption srenvironmen
> t {
  2.     replace total_scoreAL = total_scoreAL + `var'
  3.     replace count_nonzeroAL = count_nonzeroAL + (`var' != 0)
  4. }
(3,080 real changes made)
(3,080 real changes made)
(2,972 real changes made)
(2,972 real changes made)
(3,085 real changes made)
(3,085 real changes made)
(3,030 real changes made)
(3,030 real changes made)
(3,083 real changes made)
(3,083 real changes made)
(3,080 real changes made)
(3,080 real changes made)
(3,027 real changes made)
(3,027 real changes made)
(2,627 real changes made)
(2,627 real changes made)

. 
. * Calculate the average score, avoiding division by zero
. gen libValues = .
(3,349 missing values generated)

. replace libValues = total_scoreAL / count_nonzeroAL if count_nonzeroAL > 0
(3,102 real changes made)

. 
. // Life satisfaction
. *Rename and delete missing values
. rename V241621 lifesat 

. replace lifesat = . if inlist(lifesat, -9, -8, -5, -1)
(304 real changes made, 304 to missing)

. 
. *now reverse, so happiness is coded high
. egen maxval = max(lifesat)

. gen reversed_lifesat = maxval + 1 - lifesat
(304 missing values generated)

. drop maxval

. 
. *Standardize lifesat from 1-2, so it's like other dependent variables in the book
. foreach var in reversed_lifesat {
  2.     summarize `var'
  3.     gen s`var' = 1 + (`var' - r(min)) / (r(max) - r(min))
  4. }

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
reversed_l~t |      3,045    3.565846    .9927543          1          5
(304 missing values generated)

. 
. rename sreversed_lifesat LifeSat

. 
. // Demographics
. *Drop missing values and rename
. replace V241177=. if V241177==99
(542 real changes made, 542 to missing)

. replace V241177=. if V241177<0
(24 real changes made, 24 to missing)

. rename V241177 libconsp

. 
. rename V241566x income 

. replace income=. if income<0
(437 real changes made, 437 to missing)

. 
. replace V241491=. if V241491<0
(1,473 real changes made, 1,473 to missing)

. rename V241491 unemployment

. 
. rename V241458x age 

. replace age=. if age<0
(175 real changes made, 175 to missing)

. egen age_centered = mean(age) 

. replace age_centered = age - age_centered
(3,349 real changes made, 175 to missing)

. gen age_centered_squared = age_centered^2
(175 missing values generated)

. 
. *Create dummies
. gen FemaleGender=.
(3,349 missing values generated)

. replace FemaleGender=1 if V241551==1
(1,416 real changes made)

. replace FemaleGender=2 if V241551==2
(1,612 real changes made)

. 
. egen maxval = max(unemployment)

. gen Unemployed = maxval + 1 - unemployment
(1,473 missing values generated)

. drop maxval 

. 
. gen ReligiousAtt=. 
(3,349 missing values generated)

. replace ReligiousAtt=0 if V241441==-1
(2,873 real changes made)

. replace ReligiousAtt=1 if inlist(V241441, 1, 2)
(476 real changes made)

. 
. gen Graduate=.
(3,349 missing values generated)

. replace Graduate=0 if inrange(V241465x, 1, 3)
(1,895 real changes made)

. replace Graduate=1 if inlist(V241465x, 4, 5)
(1,403 real changes made)

. 
. gen Married=.
(3,349 missing values generated)

. replace Married=1 if V241461x==1
(1,588 real changes made)

. replace Married=0 if inrange(V241461x, 2, 5)
(1,747 real changes made)

. 
. // Standardize variables 
. egen Age = std(age_centered_squared) 
(175 missing values generated)

. egen Income = std(income)
(437 missing values generated)

. egen LibValues = std(libValues)
(247 missing values generated)

. egen SocJusValues = std(socJusValues)
(252 missing values generated)

. 
. // Regressions
. 
. regress LifeSat SocJusValues [pweight=V240105a], robust 
(sum of wgt is 3,099.68149423049)

Linear regression                               Number of obs     =      3,041
                                                F(1, 3039)        =       0.01
                                                Prob > F          =     0.9377
                                                R-squared         =     0.0000
                                                Root MSE          =     .24066

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
SocJusValues |   .0004782   .0061174     0.08   0.938    -.0115165    .0124729
       _cons |   1.656469   .0061208   270.63   0.000     1.644468    1.668471
------------------------------------------------------------------------------

. eststo
(est1 stored)

. regress LifeSat SocJusValues Age FemaleGender Graduate Income Married ReligiousAtt Unemployed [pweight=V24010
> 5a], robust 
(sum of wgt is 1,878.83399101924)

Linear regression                               Number of obs     =      1,680
                                                F(8, 1671)        =      10.28
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0767
                                                Root MSE          =     .22272

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
SocJusValues |   .0102331   .0072687     1.41   0.159    -.0040237    .0244899
         Age |  -.0113367   .0086494    -1.31   0.190    -.0283014     .005628
FemaleGender |  -.0127187    .015219    -0.84   0.403    -.0425691    .0171317
    Graduate |   .0465115   .0161034     2.89   0.004     .0149265    .0780965
      Income |   .0167435   .0109291     1.53   0.126    -.0046927    .0381798
     Married |   .0698081    .016663     4.19   0.000     .0371256    .1024907
ReligiousAtt |   .0441467   .0226346     1.95   0.051    -.0002484    .0885418
  Unemployed |  -.0579248   .0314454    -1.84   0.066    -.1196013    .0037517
       _cons |   1.667099   .0456845    36.49   0.000     1.577494    1.756704
------------------------------------------------------------------------------

. eststo
(est2 stored)

. regress LifeSat LibValues [pweight=V240105a], robust 
(sum of wgt is 3,103.44220434307)

Linear regression                               Number of obs     =      3,045
                                                F(1, 3043)        =       0.10
                                                Prob > F          =     0.7558
                                                R-squared         =     0.0001
                                                Root MSE          =     .24079

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
   LibValues |  -.0018797   .0060429    -0.31   0.756    -.0137284    .0099689
       _cons |    1.65689   .0061041   271.44   0.000     1.644921    1.668858
------------------------------------------------------------------------------

. eststo
(est3 stored)

. regress LifeSat LibValues Age FemaleGender Graduate Income Married ReligiousAtt Unemployed [pweight=V240105a]
> , robust 
(sum of wgt is 1,882.41717594631)

Linear regression                               Number of obs     =      1,683
                                                F(8, 1674)        =      10.25
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0756
                                                Root MSE          =     .22308

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
   LibValues |   .0049836   .0076578     0.65   0.515    -.0100363    .0200034
         Age |  -.0110475   .0086004    -1.28   0.199    -.0279163    .0058212
FemaleGender |  -.0100759   .0150879    -0.67   0.504    -.0396691    .0195173
    Graduate |   .0487673   .0162821     3.00   0.003     .0168319    .0807027
      Income |   .0161497   .0108962     1.48   0.138    -.0052219    .0375212
     Married |   .0680823   .0165399     4.12   0.000     .0356411    .1005234
ReligiousAtt |    .046022   .0226604     2.03   0.042     .0015763    .0904678
  Unemployed |  -.0582932   .0316166    -1.84   0.065    -.1203055    .0037191
       _cons |   1.664178   .0458493    36.30   0.000      1.57425    1.754106
------------------------------------------------------------------------------

. eststo
(est4 stored)

. regress LifeSat SocJusValues LibValues Age FemaleGender Graduate Income Married ReligiousAtt Unemployed [pwei
> ght=V240105a], robust 
(sum of wgt is 1,878.83399101924)

Linear regression                               Number of obs     =      1,680
                                                F(9, 1670)        =       9.14
                                                Prob > F          =     0.0000
                                                R-squared         =     0.0771
                                                Root MSE          =     .22275

------------------------------------------------------------------------------
             |               Robust
     LifeSat | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
SocJusValues |   .0152667   .0118313     1.29   0.197     -.007939    .0384724
   LibValues |  -.0069371   .0123625    -0.56   0.575    -.0311847    .0173104
         Age |  -.0109889   .0086448    -1.27   0.204    -.0279448    .0059669
FemaleGender |  -.0124878   .0152054    -0.82   0.412    -.0423115    .0173359
    Graduate |   .0477256   .0162681     2.93   0.003     .0158176    .0796337
      Income |   .0172663   .0109652     1.57   0.116    -.0042406    .0387732
     Married |   .0693117   .0166254     4.17   0.000     .0367029    .1019204
ReligiousAtt |   .0428552   .0228247     1.88   0.061    -.0019128    .0876231
  Unemployed |  -.0579088   .0314495    -1.84   0.066    -.1195934    .0037758
       _cons |   1.667029   .0457373    36.45   0.000      1.57732    1.756737
------------------------------------------------------------------------------

. eststo
(est5 stored)

. esttab

--------------------------------------------------------------------------------------------
                      (1)             (2)             (3)             (4)             (5)   
                  LifeSat         LifeSat         LifeSat         LifeSat         LifeSat   
--------------------------------------------------------------------------------------------
SocJusValues     0.000478          0.0102                                          0.0153   
                   (0.08)          (1.41)                                          (1.29)   

Age                               -0.0113                         -0.0110         -0.0110   
                                  (-1.31)                         (-1.28)         (-1.27)   

FemaleGender                      -0.0127                         -0.0101         -0.0125   
                                  (-0.84)                         (-0.67)         (-0.82)   

Graduate                           0.0465**                        0.0488**        0.0477** 
                                   (2.89)                          (3.00)          (2.93)   

Income                             0.0167                          0.0161          0.0173   
                                   (1.53)                          (1.48)          (1.57)   

Married                            0.0698***                       0.0681***       0.0693***
                                   (4.19)                          (4.12)          (4.17)   

ReligiousAtt                       0.0441                          0.0460*         0.0429   
                                   (1.95)                          (2.03)          (1.88)   

Unemployed                        -0.0579                         -0.0583         -0.0579   
                                  (-1.84)                         (-1.84)         (-1.84)   

LibValues                                        -0.00188         0.00498        -0.00694   
                                                  (-0.31)          (0.65)         (-0.56)   

_cons               1.656***        1.667***        1.657***        1.664***        1.667***
                 (270.63)         (36.49)        (271.44)         (36.30)         (36.45)   
--------------------------------------------------------------------------------------------
N                    3041            1680            3045            1683            1680   
--------------------------------------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

.  
. log close
      name:  <unnamed>
       log:  C:\Users\sbstjp\OneDrive - Cardiff University\FinalHarvard\Appendix3.2.log
  log type:  text
 closed on:  12 May 2025, 17:47:58
---------------------------------------------------------------------------------------------------------------
